/****** impoer excel diem vi pham ******/
diemvipham = function()
{	
	this.attrNames = [],
	this.inputFile = '#input_Map_Bandoquyhoach_Diemvipham_ImageUpload_Action',
	this.create = function()
	{
		var optionSplit = arguments[0].split(';');
		if (optionSplit.length == 0) return;
		var i = 0;
		for (i = 0; i < optionSplit.length; i++) {
			var sAttr = optionSplit[i];
			sAttr = sAttr.split(':');
			if (sAttr.length != 2)
				continue;
			var sKey = base.trim(sAttr[0]).toLowerCase();
			var sValue = base.trim(sAttr[1]);
			this.attrNames[sKey] = sValue;
		}
		return this;
	};
	
	this.importExcelDVP = function()
	{
		if($(this.inputFile).val() == '')
		{
			alert(LANGUAGE["msg_import_excel_empty"]);
			return;
		}
		excelTool.arrayAsset = [];
		var objDiemViPham = $("#divPreview_Map_Bandoquyhoach_Diemvipham_ImageUpload_Action").text();
		objDiemViPham = base.trim(objDiemViPham.replace(/(\r\n|\n|\r)/gm, ""));
		if(objDiemViPham == "0")
		{
			alert(LANGUAGE["msg_import_excel_empty"]);		
		}
		else if(objDiemViPham == "1")
		{
			alert(LANGUAGE["msg_import_excel_not_avalid"]);
		}
		else
		{
			this.arrayXML = new Array();
			 FLAG_COMPLETETED = false;
			 
			 var url_excel_file = sPortletReadExcel + "coordinate.xml";
			 
			 $.get(url_excel_file, function (data) {
				    $(data).find('elements').each(function () {
				        var $alias = $(this);
				        $alias.find('element').each(function () {
				            var $fieldAlias = $(this);
				            var _mavipham = "";
				            if($fieldAlias.attr('node0') != null) _mavipham = $fieldAlias.attr('node0');
				            var _tennguoivipham = "";
				            if($fieldAlias.attr('node1') != null) _tennguoivipham = $fieldAlias.attr('node1');
				            var _diachi = "";
				            if($fieldAlias.attr('node2') != null) _diachi = $fieldAlias.attr('node2');
				            var _solodat = "";
				            if($fieldAlias.attr('node3') != null) _solodat = $fieldAlias.attr('node3');
				            var _lodatthua = "";
				            if($fieldAlias.attr('node4') != null) _lodatthua = $fieldAlias.attr('node4');
				            var _tothuabando = "";
				            if($fieldAlias.attr('node5') != null) _tothuabando = $fieldAlias.attr('node5');
				            var _tinhtrangvipham = "";
				            if($fieldAlias.attr('node6') != null) _tinhtrangvipham = $fieldAlias.attr('node6');
				            var _dientich = "";
				            if($fieldAlias.attr('node7') != null) _dientich = parseFloat($fieldAlias.attr('node7'));
				            var _sonha = "";
				            if($fieldAlias.attr('node8') != null) _sonha = $fieldAlias.attr('node8');
				            var _matuyendg = "";
				            if($fieldAlias.attr('node9') != null) _matuyendg = $fieldAlias.attr('node9');
				            var _maquan = "";
				            if($fieldAlias.attr('node10') != null) _maquan = parseInt($fieldAlias.attr('node10'));
				            var _maphuong = "";
				            if($fieldAlias.attr('node11') != null) _maphuong = parseInt($fieldAlias.attr('node11'));
				            var _ngayvipham = "";
				            if($fieldAlias.attr('node12') != null)
			            	{
				            	// format: dd-mm-yyyy
				            	_ngayvipham = $fieldAlias.attr('node12');
				            	_ngayvipham = _ngayvipham.split('-');
				            	// format: yyyy-mm-dd
				            	_ngayvipham = _ngayvipham[2] + '-' + _ngayvipham[1] + '-' + _ngayvipham[0];
			            	}
				            var _ghichu = "";
				            if($fieldAlias.attr('node13') != null) _ghichu = $fieldAlias.attr('node13');
				            var _coorX = "";
				            if($fieldAlias.attr('node14') != null) _coorX = $fieldAlias.attr('node14');
				            var _coorY = "";
				            if($fieldAlias.attr('node15') != null) _coorY = $fieldAlias.attr('node15');		
				            var dvp = new diemvipham();
				            dvp.create("mavipham:" + _mavipham + ";tennguoivipham:" + _tennguoivipham 
				            		+ ";diachi:" + _diachi + ";solodat:" + _solodat				            		
				            		+ ";lodatthua:" + _lodatthua + ";tothuabando:" + _tothuabando
				            		+ ";tinhtrangvipham:" + _tinhtrangvipham + ";dientich:" + _dientich
				            		+ ";sonha:" + _sonha + ";matuyenduong:" + _matuyendg
				            		+ ";maquan:" + _maquan + ";maphuong:" + _maphuong
				            		+ ";ngayvipham:" + _ngayvipham + ";ghichu:" + _ghichu
				            		+ ";x:" + _coorX + ";y:" + _coorY);
				            excelTool.arrayAsset[excelTool.arrayAsset.length] = dvp; 		            
				        });
				        FLAG_COMPLETETED = true;
				        excelTool.import(excelTool.typeAsset.diemvipham, LayerAssetName.diemVipham);
				    });
				});
		}
		$("#divPreview_Map_Bandoquyhoach_Diemvipham_ImageUpload_Action").empty();
	};

	this.updateFeature = function()
	{
		
	};
};
var diemVP = new diemvipham();
/****************************************/